<?php

/**
 * @author ducnhat
 * @email ddnhat@gmail.com
 * @copyright 2014
 */
 
class ContactController extends Zenddn_Controller_Action{
	
    public function init(){
		parent::init();
        parent::loadTemplate('magashop');
        $this->view->page = "contact";
	}
    
    public function indexAction(){
    	$request = $this->_request;
        
        if($request->isPost()){
            $validator = new Default_Form_ValidateContact($request->getParams());
            
            if($validator->isError()){
                $this->view->isError = $validator->isError();
                $this->view->messageError = $validator->getMessageError();
            }else{
                $model = new Default_Model_Contact();
                $model->saveData($validator->getData());
                
                $this->_helper->_redirector->gotoRoute(array('controller' => 'contact', 'action' => 'success'), null, true);
            }
        }
    }
    
    public function warrantyAction(){
    	$request = $this->_request;
        
        if($request->isPost()){
            $validator = new Default_Form_ValidateContact($request->getParams(), true);
            
            if($validator->isError()){
                $this->view->isError = $validator->isError();
                $this->view->messageError = $validator->getMessageError();
            }else{
                $model = new Default_Model_Contact();
                $model->saveData($validator->getData());
                
                $this->_helper->_redirector->gotoRoute(array('controller' => 'contact', 'action' => 'success'), null, true);
            }
        }
    }
    
    public function successAction(){
    	
    }
}